package dk.aiszone.lang.messer.autosource.interfaces;

import dk.aiszone.lang.autosource.generatorobjects.interfaces.GeneratorObject;
import dk.aiszone.lang.messer.MesserLog;

/**
 * Abstract class extended by statements which can be altered.
 * 
 * @author Ais
 */
public abstract class AbstractModifiableObject extends GeneratorObject implements ModifiableObject {

    /** The column number of the statement */
    protected final int column;
    /** The row number of the statement */
    protected final int row;

    /**
     * COnstructor for the <code>ModifiableStatement</code>.
     * 
     * @param row
     *            The line of the <code>ModifialbleStatement</code>.
     * @param column
     *            The column of the <code>ModifiableStatement</code>.
     */
    protected AbstractModifiableObject(int row, int column) {
        this.row = row;
        this.column = column;
    }

    public int getColumn() {
        return column;
    }

    public int getRow() {
        return row;
    }

    @Override
    public final boolean isModifiable() {
        return getNumberOfSupportedModifications() > 0;
    }

    /**
     * Log the change to the <code>MesserLog</code>.
     * 
     * @param original
     *            The orignal statement.
     * @param change
     *            The modified statement.
     */
    protected void log(String original, String change) {
        MesserLog.instance().addChange(row, column, original, change);
    }
}